/**
* Created by admin on 2018/3/10.
*/
<template>
  <section class="orderBox">
    <el-form :model="userInfo" :rules="userRules" ref="userInfo" label-width="100px" class="demo-userInfo">
      <el-row>
        <el-col :span="8">
          <el-form-item label="组织名称" prop="realName">
            <el-input v-model="userInfo.realName" :disabled="userDisable" clearable></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="联系号码" prop="mobileNumber">
            <el-input v-model="userInfo.mobileNumber" :disabled="userDisable" clearable></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="邮箱" prop="email">
            <el-input v-model="userInfo.email" :disabled="userDisable" clearable></el-input>
          </el-form-item>
        </el-col>
      </el-row>

      <el-row>
        <el-col :span="8">
          <el-form-item label="组织地址" prop="address">
            <el-input v-model="userInfo.address" :disabled="userDisable" clearable></el-input>
          </el-form-item>
        </el-col>
        <el-col :span="8">
          <el-form-item label="目前人数" prop="orginzerCount">
            <el-input v-model="userInfo.orginzerCount" :disabled="userDisable" clearable></el-input>
          </el-form-item>
        </el-col>
        <!--<el-col :span="8">-->
          <!--<el-form-item label="专业" prop="major">-->
            <!--<el-input v-model="userInfo.major" :disabled="userDisable" clearable></el-input>-->
          <!--</el-form-item>-->
        <!--</el-col>-->
      </el-row>

      <el-row>
        <el-col :span="12">
          <el-form-item label="组织口号" prop="slogan">
            <el-input v-model="userInfo.slogan" :disabled="userDisable" type="textarea"
                      :autosize="{ minRows: 4, maxRows: 8}"></el-input>
            <!--<el-input v-model="userInfo.email" :disabled="userDisable" clearable></el-input>-->
          </el-form-item>
        </el-col>

    </el-row>

      <el-row>
        <el-col :span="12" :offset="6">
          <el-form-item>
          <el-button type="primary" @click="editForm">编辑</el-button>
          <el-button type="success" @click="userFormSubmit('userInfo')">保存</el-button>
          </el-form-item>
        </el-col>
      </el-row>

    </el-form>
    <div class="divid-line"></div>
</section>
</template>
<script>
  import DataUtil from '../../common/dataUtil.js'
  import ElRow from "element-ui/packages/row/src/row";
  import ElCol from "element-ui/packages/col/src/col";
  import ElInput from "../../../node_modules/element-ui/packages/input/src/input";
  export default {
    components: {
      ElInput,
      ElCol,
      ElRow},
    data() {
      var emaliValitor = (rule, value, callback) => {
        var regex = /^([0-9A-Za-z\-_\.]+)@([0-9a-z]+\.[a-z]{2,3}(\.[a-z]{2})?)$/g;
        if (value === '') {
          callback(new Error('邮箱不能为空！'));
        } else if (!regex.test(value)) {
          callback(new Error('邮箱格式不合法！'));
        } else {
          callback();
        }
      };
      var sexValitor = (rule, value, callback) => {
        if (value === 0) {
          callback(new Error('请选择性别！'));
        } else {
          callback();
        }
      };
//      var orginzerValitor = (rule, value, callback) => {
//        if (value === 0) {
//          callback(new Error('请选择政治面貌！'));
//        } else {
//          callback();
//        }
//      };
      return {
        userInfo: {
        },
        userDisable: true,
        userRules: {
          realName: [
            { required: true, message: '组织名称不能为空！', trigger: 'blur' },
          ],
          email: [
            { required: true, validator: emaliValitor, trigger: 'blur' }
          ],
//          orginzerCount: [
//            { required: true, validator: orginzerValitor, trigger: 'blur' }
//          ],
          mobileNumber: [
            { required: true, message: '请填写组织联系号码！', trigger: 'blur' }
          ],
          address: [
            { required: true, message: '请填写组织所在地址！', trigger: 'blur' }
          ],
//          slogan: [
//        { required: true, message: '请填写口号！', trigger: 'blur' }
//      ]
        }
      };
    },
    methods: {

      userFormSubmit(formName) {
        this.$refs[formName].validate((valid) => {
          if (valid) {
            let _data = Object.assign({}, this.userInfo);
            this.$http.post('user/insertOrUpdateUser', _data).then(response => {
               if (response.body.code == 1) {
                     this.$message({
                       type : 'success',
                       message : '修改个人信息成功！'
                     })
                 this.userDisable = true;
                 }
            });
          } else {
            this.$message.error('修改个人信息失败！');
            return false;
          }
        });
      },
      editForm() {
        this.userDisable = false;
      },
      getUserInfo(){

          this.$http.post('user/getUserById',{'id':DataUtil.id()}).then(response => {
             if (response.body.code == 1) {
                 this.userInfo = response.body.data;
             }
          });

      },
    },
    mounted: function () {
      this.getUserInfo();
    }
  }
</script>


  <style>
  .reviewTable {
    width: 80%;
    border-spacing: 0;
    border: 1px solid gray;
    margin: 20px auto;
  }
  .reviewTable td {
    text-align: center;
    border: 1px solid gray;
    height: 40px;
    line-height: 40px;

    width: 50%;
    word-wrap:break-word;
  }
  .videos {
    width: 80%;
    margin: 20px auto;
  }
  /*侧边框布局*/
  .containers {
    width: 100%;
    /*height: 400px;*/
    display: flex;

  }
  .containers .asides {
    flex: 6;

  }
  .containers .mains {
    flex: 4;
    margin-left: 40px;
  }
  .other_remark {
    width: 100%;
  }
  .mains .smallRemark {
    width: 100%;
  }
  .asides table {
    border-spacing: 0;
    border: 1px solid #A9A9A9 ;
    border-radius: 2px;
  }
  .asides table td {
    border: .5px solid #efefef;
    word-wrap:break-word;
    line-height: 20px;
    padding: 5px;
  }
  table td img {
    width: 100%;
  }
  .aside_title {
    font-weight: 400;
    line-height: 40px;
    font-size: 16px;
  }
  .question_radio {
    padding-bottom: 30px;
    margin: 5px 10px;
  }
  .question_radio .radio_box {
    /*margin-bottom: -30px;*/
    line-height: 20px;
    float: right;
  }
  .addreBook {
    text-align: center;
    width: 40px;
  }
  /* 标题 */
  .main-title{
    font-size: 22px;
    margin-top: -15px;
    margin-bottom: 15px;
  }
  .one-title{
    font-size: 18px;
    font-weight: bold;
    margin-bottom: 7px;
  }
  .two-title{
    font-size: 13px;
    color: #888;
    margin: 10px 0
  }
  .subtitle{
    font-size: 13px;
    color: #888;
  }
  .orderBox .el-row {
    margin: 8px 30px;
  }
  .orderBox .el-col span{
    margin-right: 10px;
  }
  .orderBox .el-button span,.orderBox .el-tag span{
    margin-right: 0;
  }
  .orderBox .box-card .el-button{
    margin-right: 5px;
  }
  .orderBox .grid-content {
    line-height: 28px;
  }

  .divid-line{
    height: 10px;
    background: #f1f2f7;
  }
  /*借款信息*/
  .loanDetail{
    margin: 0 30px 15px;
    width: 94%;
    max-height:250px;
  }
  /*依图识别*/
  .yituInfo{
    display: block;
    text-align: center;
    margin-top: 10px;
  }
  /*征信*/
  .orderBox .box-card{
    height: 225px;
  }
  .JXLBox{
    border: 1px solid #ccc;
    padding: 10px
  }
  .JXLBox div{
    padding: 5px;
  }

  .orderBox .el-table .info-row {
    background: #e2f0e4;
  }

  .orderBox .el-table .red-row{
    background: #F33;
  }
  .redInfo{
    color: #F33;
  }

  .line-height .el-col{
    margin-bottom: 10px;
  }
  .faceCheck {
    margin: 0 auto;
    overflow: hidden;
  }
  .faceCheck .faceImg{
    width: 45%;
    height: 350px;
    overflow: hidden;
    margin: 1.5%;
    float: left;
    text-align: center;
  }
  .faceCheck .faceImg img {
    margin: 0 auto;
    display: block;
    width: 90%;
    height: 90%;
/*    border: .5px solid #F1F2F7;
border-radius: 5px;*/
}
.faceImgTop img{
  margin: 0 auto;
  height: 200px;
  display: block;
  max-height: 100%;
  max-width: 100%;
  min-width: 65%;
  min-height: 65%;
  border: .5px solid #F1F2F7;
  border-radius: 5px;
}
.faceImgBottom img{
  margin: 0 auto;
  display: block;
  height: 300px;
  min-width: 80%;
  min-height: 80%;
  border: .5px solid #F1F2F7;
  border-radius: 5px;
}
table td img {
  width: 100%;
}
.faceImgTop .handleImg {
  width: 40%;
  transform: rotate(-90deg);
  -webkit-transform: rotate(-90deg);
}
</style>
